/**
 * 
 */
package fr.utbm.gi.vi51.slizers.framework.agent;

import java.util.Random;

/**
 * Enum for a direction in an environment.
 *
 * @author Tarik Belabbas
 *
 */
public enum Direction
{
	LEFT( -1, 0 )
	{
		/* (non-Javadoc)
		 * @see fr.utbm.gi.vi51.slizers.framework.environment.Direction#opposite()
		 */
		@Override
		public Direction opposite()
		{
			return RIGHT;
		}
	},
	RIGHT( +1, 0 )
	{
		/* (non-Javadoc)
		 * @see fr.utbm.gi.vi51.slizers.framework.environment.Direction#opposite()
		 */
		@Override
		public Direction opposite()
		{
			return LEFT;
		}
	};

	/**
	 * The x-coordinate difference.
	 */
	public final int	dx;
	
	/**
	 * The y-coordinate difference.
	 */
	public final int	dy;

	/**
	 * Parameterized constructor.
	 * 
	 * @param x the x-coordinate difference.
	 * @param y the y-coordinate difference.
	 */
	Direction( int _x, int _y )
	{
		this.dx = _x;
		this.dy = _y;
	}

	/**
	 * Returns a random direction.
	 * 
	 * @return a random direction
	 */
	public static Direction random()
	{
		Random random = new Random();
		return values()[ random.nextInt( values().length ) ];
	}

	/**
	 * Returns the opposite direction.
	 * 
	 * @return the opposite direction
	 */
	public abstract Direction opposite();
}
